package cn.gson.springmvc.commons;

import org.springframework.mail.MailParseException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

public class MyExceptionHandller extends HandlerInterceptorAdapter {
    private int ir;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView model) throws Exception {
        Map<String,Object> map=model.getModel();
        int ir=(int)map.get("ir");
        if(ir%3==0){
            ir=ir*10;
        }
        model.addObject("ir",ir);
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

    }
}
